<html>
<head><meta charset="utf-8"><title>Deprecate {integer}::max_value and min_value methods · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html">Deprecate {integer}::max_value and min_value methods</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204903911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204903911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204903911">(Jul 24 2020 at 11:16)</a>:</h4>
<p>I'm preparing a PR to deprecate <code>{integer}::{min,max}_value</code> methods<br>
in favour of associated constants <code>{MAX,MIN}</code>.<br>
Unlike <code>std::{integer}::{MAX,MIN}</code> which can be imported,<br>
<code>{max,min}_value</code> cannot and has to be annotated<br>
with <code>#[inline(always)]</code> to be inline-able in debug builds.<br>
<code>{MAX,MIN}</code> associated constant doesn't have that limitation<br>
and is able to replace them in all uses.</p>
<p>I would like to hear your thoughts on this.</p>



<a name="204908499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204908499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BurntSushi <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204908499">(Jul 24 2020 at 12:20)</a>:</h4>
<p>i continue to be pretty "meh" on deprecations like this. i think their best use is when we actively don't want people to use older APIs for some reason or another. but in this case, the older APIs really aren't hurting anything. for cases like this, i'd either prefer not deprecating them, or perhaps more pragmatically, lump them into a group of similar deprecations that we do at the same time. (for an edition release?)</p>



<a name="204909941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204909941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204909941">(Jul 24 2020 at 12:39)</a>:</h4>
<p>You has a point.<br>
However, currently we have 3 ways to use max/min value of integers: <br>
the const method (1), the associated constant (2), and the module constant (3).<br>
(1) and (2) are overlapping with each other in all use-cases. </p>
<ul>
<li>
<p>This causes styling issue.<br>
Projects might prefer (2) but new contributors might use (1).<br>
This is not being enforced by any automatic tools but reviewers and guidelines.</p>
</li>
<li>
<p>Another weak point is (1) makes rustc doing more work for the same purpose, especially in debug mode.</p>
</li>
</ul>



<a name="204911059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204911059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BurntSushi <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204911059">(Jul 24 2020 at 12:52)</a>:</h4>
<p>yeah, sure, i definitely admit that having multiple different ways to get at the constants isn't ideal.</p>



<a name="204913171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204913171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204913171">(Jul 24 2020 at 13:13)</a>:</h4>
<p>The main reason to prefer the module constant instead of the type constant is because of minimum rust version support. If you care about that and your CI isn't enforcing it you should get better CI.</p>



<a name="204913465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204913465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204913465">(Jul 24 2020 at 13:16)</a>:</h4>
<p>yeah, I know that. So here I'm not suggesting deprecating module constant.<br>
Edit: To clarify, module constant can be imported, but type constant and const method cannot.<br>
So I don't suggest deprecating module constant.<br>
About MRVS, I think rustc project only care about stable version.</p>



<a name="204915983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204915983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204915983">(Jul 24 2020 at 13:39)</a>:</h4>
<p>I would be pretty strongly opposed to deprecating in the current edition.</p>



<a name="204916018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204916018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204916018">(Jul 24 2020 at 13:39)</a>:</h4>
<p>I also think we should deprecate all but one at the same time.</p>



<a name="204916779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204916779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204916779">(Jul 24 2020 at 13:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3A.7Bmin.2Cmax.7D_value.20methods/near/204916018">said</a>:</p>
<blockquote>
<p>I also think we should deprecate all but one at the same time.</p>
</blockquote>
<p>Could you clarify? What all?</p>



<a name="204917024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204917024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204917024">(Jul 24 2020 at 13:48)</a>:</h4>
<p>We have three ways of getting min/max today: module constants, methods, and type constants. I think if the consensus is that the type constants are the "right way" then those should be the only ones left after we deprecate. I think deprecating module consts and methods in 2021 edition makes sense.</p>



<a name="204917092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204917092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204917092">(Jul 24 2020 at 13:49)</a>:</h4>
<p>but we currently have no way to import type constant.</p>



<a name="204917180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204917180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204917180">(Jul 24 2020 at 13:50)</a>:</h4>
<p>IMO, that's not a problem.</p>



<a name="204917262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204917262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204917262">(Jul 24 2020 at 13:51)</a>:</h4>
<p>If users really want the <code>MAX</code> name in the namespace, they can define their own constants -- I consider <code>use std::u8::MAX;</code> to pretty much always be a bad idea, and deprecating that is I think an improvement.</p>



<a name="204921033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204921033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204921033">(Jul 24 2020 at 14:20)</a>:</h4>
<blockquote>
<p>About MRVS, I think rustc project only care about stable version.</p>
</blockquote>
<p>I absolutely, and in the strongest possible terms, disagree with this idea.</p>



<a name="204921466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204921466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204921466">(Jul 24 2020 at 14:23)</a>:</h4>
<p>That's what I see from compiler devs opinions.<br>
It's true that people are trying with RFC about MRVS.<br>
But If compiler devs care about MRVS, they will patch any security in older stable releases, not just the current stable.</p>



<a name="204921814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204921814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204921814">(Jul 24 2020 at 14:26)</a>:</h4>
<p>I don't really know how that has relevance to this discussion though?</p>
<p>In some sense, sure, you could say "deprecating now is fine" because the old versions are unsupported and everyone should be on latest stable and keeping up with deprecations. I think that's not a good attitude to take, though, and <em>especially</em> when the pain caused by deprecation gives you no benefit - it's not like the new way is any better for old code - we should strive to avoid making people migrate (or slap <code>#[allow(deprecated)]</code> on their crate).</p>



<a name="204922061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204922061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204922061">(Jul 24 2020 at 14:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3A.7Bmin.2Cmax.7D_value.20methods/near/204917262">said</a>:</p>
<blockquote>
<p>If users really want the <code>MAX</code> name in the namespace, they can define their own constants</p>
</blockquote>
<p>That's kind of tedious when you have to re-define the constant. But I'm fine with it.</p>
<p>One more question. Can we make the deprecation work only for Rustc codebase?</p>



<a name="204922935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204922935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204922935">(Jul 24 2020 at 14:34)</a>:</h4>
<p>Well, it is tedious, I guess, but the cases where people would actually do this seem slim-to-none</p>



<a name="204923033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204923033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204923033">(Jul 24 2020 at 14:35)</a>:</h4>
<p>I don't know what you mean "only for rustc codebase"</p>



<a name="204923105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204923105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204923105">(Jul 24 2020 at 14:35)</a>:</h4>
<p>I don't personally think rustc is in any special place wrt to min/max</p>



<a name="204923204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204923204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204923204">(Jul 24 2020 at 14:36)</a>:</h4>
<p>Like internal lints</p>



<a name="204923250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204923250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204923250">(Jul 24 2020 at 14:36)</a>:</h4>
<p>I mean probably but I'd not personally want to maintain that, there's really no point in the hassle of reviewing and implementing that I think</p>



<a name="204923671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204923671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204923671">(Jul 24 2020 at 14:40)</a>:</h4>
<p>Because just a few days ago, I saw a rustc contributor using const method instead of type constants.<br>
Reviewer was not catching that.<br>
Not that I blame them or it is a big problems, but still type constants are preferred in all places in rustc repo.</p>
<p>Anyway, I will open an issue in clippy then.</p>



<a name="204924106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204924106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204924106">(Jul 24 2020 at 14:43)</a>:</h4>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span> I don't see it as a problem personally, they're all equally good in my eyes</p>



<a name="204924161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204924161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204924161">(Jul 24 2020 at 14:43)</a>:</h4>
<p>obviously good to standardize in the long run, but we can do that in rustc when migrating to the next edition no problem</p>



<a name="204924297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204924297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204924297">(Jul 24 2020 at 14:44)</a>:</h4>
<p>It's more as a style issue. Clippy could be a tool to enforce this.</p>



<a name="204924860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204924860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204924860">(Jul 24 2020 at 14:48)</a>:</h4>
<p>Right I mean I would personally not care but up to you if you want to pursue a clippy lint etc</p>



<a name="204938345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204938345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204938345">(Jul 24 2020 at 16:41)</a>:</h4>
<p>(deleted)</p>



<a name="204946882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204946882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204946882">(Jul 24 2020 at 17:55)</a>:</h4>
<blockquote>
<p>One more question. Can we make the deprecation work only for Rustc codebase?</p>
</blockquote>
<p>You can make the lint <code>allow</code> by default and <code>warn</code> on it in <a href="http://lib.rs">lib.rs</a>.</p>



<a name="204947004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204947004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204947004">(Jul 24 2020 at 17:56)</a>:</h4>
<p>Well, I guess that requires having a lint for this specific issue which seems little overkill</p>



<a name="204947082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204947082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204947082">(Jul 24 2020 at 17:57)</a>:</h4>
<p>Python has <code>DeprecationWarning</code> and<code>PendingDeprecationWarning</code> for this, maybe rust could do the same?</p>



<a name="204947131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204947131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204947131">(Jul 24 2020 at 17:57)</a>:</h4>
<p><a href="https://www.python.org/dev/peps/pep-0565/#additional-use-case-for-futurewarning">https://www.python.org/dev/peps/pep-0565/#additional-use-case-for-futurewarning</a></p>



<a name="204956534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204956534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204956534">(Jul 24 2020 at 19:25)</a>:</h4>
<p>There are a few things that are documented as "soft-deprecated" -- maybe that deserves a default-allow lint?</p>



<a name="204956575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204956575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204956575">(Jul 24 2020 at 19:25)</a>:</h4>
<p>we have future deprecations too</p>



<a name="204956626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/204956626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#204956626">(Jul 24 2020 at 19:26)</a>:</h4>
<p>but we can add a "soft deprecated" state too, I think</p>



<a name="205120551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205120551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Rabbit <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205120551">(Jul 27 2020 at 14:03)</a>:</h4>
<p>It is times like these where I wish we had a way to declare the minimum supported Rust version in our crates, and then Rust would shut up about any deprecation that is newer than that version. Then we'd be able to stop all this nonsense about "is it too soon to deprecate this?".</p>



<a name="205149250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205149250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205149250">(Jul 27 2020 at 18:06)</a>:</h4>
<p><span class="user-mention" data-user-id="125267">@Peter Rabbit</span> We've talked about having an MSRV field in <code>Cargo.toml</code>. Hadn't occurred to me that it would be useful for controlling deprecations as well; that seems quite reasonable.</p>



<a name="205149266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205149266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205149266">(Jul 27 2020 at 18:06)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> to using such a field for that purpose too.</p>



<a name="205156462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205156462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205156462">(Jul 27 2020 at 19:10)</a>:</h4>
<p>At this time, we still don't have a way to actually change the view of the standard library that a crate gets based on edition, right? And no concrete plans to make that step? And also we're pretty well set against doing a "rust 2.0" any time within like a decade or two?</p>
<p>So aren't all library deprecations essentially just ignorable hints anyway?</p>



<a name="205158619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205158619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205158619">(Jul 27 2020 at 19:31)</a>:</h4>
<p>well deprecation is not really a "view" and we already have <code>since = "1.45.0"</code> implemented, I think "since = "edition2021"` is not a big step.</p>



<a name="205163086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205163086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205163086">(Jul 27 2020 at 20:15)</a>:</h4>
<p>But currently it's not possible for a crate to switch to a new edition and lose access to some part of the standard library (type, method, impl, etc) compared to the previous edition. So far the compiler is only equipped to handle edition changes causing syntax changes, not other kinds of changes.</p>
<p>So given that, library deprecations are (currently) just a warning with no "teeth" to support them.</p>



<a name="205163316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205163316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205163316">(Jul 27 2020 at 20:17)</a>:</h4>
<p>Right but I think this proposal doesn't imply losing access? At least for this case of deprecation I'm fine with it having no teeth :)</p>



<a name="205165427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205165427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205165427">(Jul 27 2020 at 20:38)</a>:</h4>
<p>I suppose what I was getting at is the question of why it matters that we deprecate anything, or not deprecate anything, if the deprecations never lead to something actually going away entirely (as does happen in some other languages / apis / etc).</p>



<a name="205165568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205165568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205165568">(Jul 27 2020 at 20:39)</a>:</h4>
<p>It's annoying to put <code>#[allow(deprecated)]</code> on stuff that I need to keep using for MSRV</p>



<a name="205165671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205165671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205165671">(Jul 27 2020 at 20:40)</a>:</h4>
<p>But otherwise, deprecations are useful to nudge people toward better APIs</p>



<a name="205169038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205169038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205169038">(Jul 27 2020 at 21:13)</a>:</h4>
<p>Yeah, there are teaching resources that use old APIs because of the time they were written in, and you might not know that you should use something else without the warning.</p>



<a name="205185570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205185570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205185570">(Jul 28 2020 at 00:44)</a>:</h4>
<p>I think "you should use something else" is the sticking point. For every specific deprecated method, why <em>should</em> you use something else? In languages that actually remove public APIs, it's a warning to prevent being blindsided when it's removed. In this case, what exactly is the harm in using <code>min_value()</code>? What is the <em>benefit</em> of using <code>::MIN</code>? I agree that it's pretty weak. At best it could be a clippy lint ("use this as it's more idiomatic").</p>



<a name="205187125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205187125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205187125">(Jul 28 2020 at 01:14)</a>:</h4>
<p>I actually recall clippy telling me to prefer min_value for a while XD</p>



<a name="205204987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205204987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Rabbit <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205204987">(Jul 28 2020 at 07:32)</a>:</h4>
<p><code>since = "edition2021"</code> seems like it would be useful, but we should be careful to only use it in cases where that function is being replaced by something that is only available in a newer edition. Otherwise it is much better to use <code>since = "1.45.0"</code> style deprecations with smart MSRV behavior.</p>



<a name="205496634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205496634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205496634">(Jul 30 2020 at 15:55)</a>:</h4>
<p>I thought <code>accessible("i32::MIN")</code> is more preferable over <code>since = "1.45.0"</code>?</p>



<a name="205668176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/205668176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#205668176">(Aug 01 2020 at 06:36)</a>:</h4>
<p>Is this a place were we could do <code>since="2.0.0"</code> (or whatever that thing was that was added) so that the docs have the yellow pointer to the constants, but nobody gets warnings about it?</p>



<a name="206173550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/206173550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#206173550">(Aug 06 2020 at 17:44)</a>:</h4>
<blockquote>
<p>What is the benefit of using ::MIN? </p>
</blockquote>
<p>I'd say this is on the same level as nudging people towards "idiomatic Rust". It's good for the ecosystem if there's a common way things are done. We lint to make people use snake_case functions and CamelCase types, it seems equally appropriate to lint to make people use "the right way" of getting the min/max value of some int type.</p>



<a name="206173635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/206173635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#206173635">(Aug 06 2020 at 17:44)</a>:</h4>
<p>this is unlike other deprecations where the deprecated method is actually "wrong" in some sense (like it has undesirable behavior that we cannot change, or it is incorrectly not unsafe, or so)</p>



<a name="206392929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Deprecate%20%7Binteger%7D%3A%3Amax_value%20and%20min_value%20methods/near/206392929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Deprecate.20.7Binteger.7D.3A.3Amax_value.20and.20min_value.20methods.html#206392929">(Aug 09 2020 at 12:28)</a>:</h4>
<blockquote>
<p>We lint to make people use snake_case functions and CamelCase types, it seems equally appropriate to lint to make people use "the right way" of getting the min/max value of some int type.</p>
</blockquote>
<p>I’m fine with that, but as you and I both said; that’s a <em>lint</em>. I disagree that it’s a deprecation. Even if deprecations happen to be implemented as lints. </p>
<p>Requiring using <code>dyn</code> could be seen as a deprecation as we would like to remove the ability to omit it. Right now, using <code>'_</code> is just a lint as there’s no push to make omitting it required. </p>
<p>So I guess if there’s a plan to make the methods unavailable in a future edition (which there’s some chatter about) then a deprecation makes sense. Otherwise just a lint.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>